<template>
  <div class="search-page">
    <!-- 导航栏 -->
    <van-nav-bar
      title="账号登录"
      left-arrow
      @click-left="onClickLeft"
      class="color"
    />

    <!-- 登录表单 -->
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请输入账号' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请输入密码' }]"
      />
      <div style="margin: 16px">
        <van-button
          block
          type="info"
          native-type="submit"
          color=" #07c160"
          to="article"
          >登录</van-button
        >
      </div>
    </van-form>
    <!-- 跳转路由 -->
    <router-link class="link" to="/setting">注册账号</router-link>
  </div>
</template>

<script>
import { search } from "@/api/user";

export default {
  name: "search-page",
  data() {
    return { username: "qwer", password: "12345" };
  },
  methods: {
    async onSubmit(values) {
      console.log("submit", values);

      const data = await search(values);
      this.$toast.success("登录成功");
      console.log(data);
    },
  },
};
</script>

<style lang="less" scoped>
.link {
  color: black;
  font-size: 12px;
  padding-right: 45%;
  float: right;
}
.color {
  background-color: #07c160;
}
</style>
